package com.color.admin.common.security.entity;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.Collection;
import java.util.Set;

/**
 * @author HaiQiu
 * @date 2022/2/21
 */
public class SecurityUser implements UserDetails, Serializable {

    private String username;
    private String password;
    private Boolean active;
    private Set<GrantedAuthority> authorities;


    public SecurityUser() {
    }

    public SecurityUser(String username, String password, Boolean active,
                        Boolean active1, Boolean active2, Boolean active3,
                        Set<GrantedAuthority> authorities) {
        this.active = active;
        this.password = password;
        this.username = username;
        this.authorities = authorities;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Boolean getActive() {
        return active;
    }

    public void setActive(Boolean active) {
        this.active = active;
    }

    public void setAuthorities(Set<GrantedAuthority> authorities) {
        this.authorities = authorities;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public String getUsername() {
        return username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return active;
    }

    @Override
    public boolean isAccountNonLocked() {
        return active;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return active;
    }

    @Override
    public boolean isEnabled() {
        return active;
    }
}
